<?php
/*
 * 企业库 创建逻辑文件
 * @package    compay
 * @author     Mark
 * @copyright  Copyright (c) 2013 ixdcw team
 * @version    $Id: da3a49131b491477482d06b1f533e23e1722aac4 $
 */

defined('IN_IXDCW') or exit('Access Denied');
require DT_CORE . '/' . $module . '/common.inc.php';
//过滤类别
User::checkLogin();
if($createSubmit){
	$category = '';
	if(!empty($cates)) {
		$category = implode(',',$cates);
		if (strlen($cates) > 6) {
			Prompt::message('企业最多不得选择多于6个分类!');
		}
	}
	if (empty($title)){
		Prompt::message('企业词条名不能为空!');
	}

	// 重名
	$item = CompanyEntry::getByTitle($title);

	if (empty($category)) {
		Prompt::message('请选择类别！','goback');
	}


	$initDoc = array(
		'title' => trim($title),
	);
	$did = CompanyEntry::add($initDoc);
	if ($did) {
		dheader("edit.php?id=$did&title=$title&category=$category");
	} else {
		Prompt::message('添加失败!请于管理员联系!');
	}
}

include template('create','company');

